﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ConfigPanels.aspx.cs" Inherits="ConfigPanels" EnableEventValidation="false" %>

<asp:Content ID="headContentID" runat="server" ContentPlaceHolderID="HeadContent">

<script type="text/javascript" src="../scripts/developer.js"></script>   

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel runat="server" ID="emptyPanel" Visible="false"></asp:Panel>

            <asp:Panel ID="listPanel" runat="server" visible="false" >
                <div align="center">
                    <h1><%=mTitlePage %></h1>
                </div>
                <asp:button runat="server" ID="addNewButton" text="Adauga nou" onclick="addNewButton_Click" />
                <hr />
                <div class="layerOverFlow">
                    <asp:GridView ID="generalGridView" runat="server" 
                    EnableModelValidation="True" 
                    AutoGenerateColumns="False" 
                    CssClass="mGrid"
                    PagerStyle-CssClass="pgr"
                    AlternatingRowStyle-CssClass="alt"
                    AllowPaging="True"         
                    PageSize="10"
                    onpageindexchanging="generalGridView_PageIndexChanging" 
                    onrowdeleting="generalGridView_RowDeleting" 
                    onselectedindexchanged="generalGridView_SelectedIndexChanged" 
                    onrowdatabound="generalGridView_RowDataBound"
                     Width="90%">
                    <AlternatingRowStyle CssClass="alt" />
                    <Columns>                        
                        <asp:BoundField DataField="PanelName" HeaderText="Panel_Name" HtmlEncode="false" /> 
                        <asp:BoundField DataField="TableName" HeaderText="Table_Name" HtmlEncode="false" />  
                        <asp:BoundField DataField="csvAlias"  HeaderText="Alias" HtmlEncode="false" />                       
                        <asp:BoundField DataField="csvInsert" HeaderText="csvInsert" HtmlEncode="false" />   
                        <asp:BoundField DataField="csvUpdate" HeaderText="csvUpdate" HtmlEncode="false" />  
                        <asp:BoundField DataField="csvSelect" HeaderText="csvSelect" HtmlEncode="false" />                  
                        <asp:BoundField DataField="csvObject" HeaderText="csvObject" HtmlEncode="false" />       
                        <asp:TemplateField HeaderText="Delete">
                            <ItemTemplate>
                                    <asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Sunteti sigur ca vreti sa stergeti?');" />
                            </ItemTemplate>
                        </asp:TemplateField>                 
                    </Columns>
                    <PagerStyle CssClass="pgr" />
                    <SelectedRowStyle BackColor="#CCCCFF" />
                </asp:GridView>
                </div>
            </asp:Panel>

            <asp:Panel ID="newPanel" runat="server" Visible="False" >
                <div align="center">
                    <h1><%=mTitlePage %></h1>
                </div>
                <div style="float:left;">
                    <div class="module">                        
                        <div class="moduleHeader">New - sheet 1</div>
                        <div class="module_content">
                            <p>
                                <label>Panel name: </label>
                                <asp:TextBox ID="addNewPanelNameTextBox" runat="server" />
                            </p> <!-- PanelName -->
                            <p>
                                <label>Tables: </label>
                                <asp:DropDownList ID="addNewTableDDL" runat="server" AutoPostBack="true" 
                                    onselectedindexchanged="addNewTableDDL_SelectedIndexChanged"  />
                            </p> <!-- Table -->                          
                            <p>
                                <label>Columns:</label>
                                 <asp:GridView ID="columnsGridView" runat="server" 
                                    EnableModelValidation="True" 
                                    AutoGenerateColumns="False" 
                                    CssClass="mGrid"
                                    PagerStyle-CssClass="pgr"
                                    AlternatingRowStyle-CssClass="alt"
                                    onrowcommand="objectGridView_RowCommand">
                                    <AlternatingRowStyle CssClass="alt" />
                                    <Columns>
                                        <asp:BoundField DataField="column_name" HeaderText="Column Name" HtmlEncode="false" />                                                     
                                        <asp:TemplateField HeaderText="Alias">
                                            <ItemTemplate>
                                                 <asp:TextBox ID="aliasTextBoxID" runat="server"></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="i" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">
                                            <ItemTemplate>
                                                <input type="checkbox" name="newInsertCB" onclick="DoTheClick(this.id,'<%=csvInsertTextBox.ClientID %>','<%# DataBinder.Eval(Container, "DataItem.column_name") %>')" id="insertCheckBoxID_<%# DataBinder.Eval(Container, "DataItem.column_name") %>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>                        
                                        <asp:TemplateField HeaderText="u" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">
                                            <ItemTemplate>
                                                <input type="checkbox" name="newUpdateCB" onclick="DoTheClick(this.id,'<%=csvUpdateTextBox.ClientID %>','<%# DataBinder.Eval(Container, "DataItem.column_name") %>')" id="updateCheckBoxID_<%# DataBinder.Eval(Container, "DataItem.column_name") %>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>    
                                        <asp:TemplateField HeaderText="s" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">                           
                                            <ItemTemplate>
                                                 <input type="checkbox" name="newSelectCB" onclick="DoTheClick(this.id,'<%=csvSelectTextBox.ClientID %>','<%# DataBinder.Eval(Container, "DataItem.column_name") %>')" id="selectCheckBoxID_<%# DataBinder.Eval(Container, "DataItem.column_name") %>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>                
                                        <asp:TemplateField HeaderText="Object">
                                            <ItemTemplate>
                                                <asp:TextBox ID="addObjectTextBoxID" runat="server" Enabled="false" Text="TextBox:::"></asp:TextBox>                                                
                                            </ItemTemplate>
                                        </asp:TemplateField>  
                                        <asp:ButtonField ButtonType="Link" CommandName="Select" HeaderText="[+]" text="[+]" />
                                    </Columns>
                                </asp:GridView>
                            </p>
                        </div>
                    </div>
                </div>
                  
                <div style="float: left;" id="addObjectDivID" runat="server" visible="false">
                    <div class="module" style="width:250px;">
                        <div class="moduleHeader">Object - sheet</div>  
                        <div class="module_content">
                            <asp:HiddenField ID="addObjectHiddenFieldID" runat="server" />
                            <p id="pObjectID" runat="server">
                                <label> Column name: </label>
                                <asp:Label ID="addColumnNameLabelID" runat="server"></asp:Label>
                            </p>
                            <p id="pToolBoxID" runat="server">
                                <label> ToolBox: </label>
                                <asp:DropDownList Width="200px" ID="addObjectDropDownList" runat="server" DataTextField="ObjectName" DataValueField="ObjectID" onselectedindexchanged="addObjectDropDownList_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                            </p>
                            <p id="pTableID" runat="server" visible="false">
                                <label> Tabele: </label>
                                <asp:DropDownList Width="200px" ID="addTableDropDownList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="addTableDropDownList_SelectedIndexChanged"></asp:DropDownList>
                            </p>
                            <p id="pKeyID" runat="server" visible="false">
                                <label> Key.ID: </label>
                                <asp:DropDownList Width="200px" ID="addKeyRowsDropDownList" runat="server" DataTextField="column_name" DataValueField="column_name"></asp:DropDownList>                           
                            </p>
                            <p id="pColumnNameID" runat="server" visible="false">
                                <label> Column Name: </label>
                                <asp:DropDownList Width="200px" ID="addNameRowsDropDownList" runat="server" DataTextField="column_name" DataValueField="column_name"></asp:DropDownList>
                            </p> 
                            <p id="pSqlID" runat="server" visible="false">
                                <lable>SQL:</lable>
                                <asp:TextBox id="addSql" runat="server" Rows="7" TextMode="MultiLine"></asp:TextBox>
                            </p>
                            <asp:Button ID="addObjectButton"  runat="server" Text="Save" onclick="addObjectSaveButton_Click"   />
                            <asp:Button ID="cancelObjectButton" runat="server" Text="Cancel"  onclick="addObjectCancelButton_Click"  />                            
                        </div>
                    </div>
                </div>
                
                <div style="float: left;">
                    <div class="module" style="width: auto;">                           
                        <div class="moduleHeader">CSV - sheet</div>  
                        <div class="module_content">                                   
                            <p>
                                <label> CSV Insert: </label>
                                <asp:TextBox ID="csvInsertTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p> <!-- ... -->    
                            <p>
                                <label> CSV Update: </label>
                                <asp:TextBox ID="csvUpdateTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p>
                            <p>
                                <label> CSV Select: </label>
                                <asp:TextBox ID="csvSelectTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p>                                    
                        </div>
                    </div>
                </div>

                <div style="float: left;">
                    <asp:Button ID="addNewSaveButton"  runat="server" Text="Save" onclick="addNewSaveButton_Click"   />
                    <asp:Button ID="addNewCancelButton" runat="server" Text="Cancel"  onclick="addNewCancelButton_Click"  />
                </div>

                <div class="clear"></div>
              
            </asp:Panel> 

            <asp:Panel ID="editPanel" runat="server" Visible="False" >
                <div align="center">
                    <h1><%=mTitlePage %></h1>
                </div>

                <div style="float: left;">
                    <div class="module">                        
                        <div class="moduleHeader">Edit - sheet 1</div>
                        <div class="module_content">
                            <p>
                                <label>Panel name: </label>
                                <asp:TextBox ID="editPanelNameTextBox" runat="server" />
                            </p> <!-- PanelName -->
                            <p>
                                <label>Tables: </label>
                                <asp:DropDownList ID="editTableDDL" runat="server" AutoPostBack="true" 
                                    onselectedindexchanged="editTableDDL_SelectedIndexChanged"  />
                            </p> <!-- Table -->                          
                            <p>
                                <label>Columns:</label>
                                 <asp:GridView ID="editColumnsGridView" runat="server" 
                                    EnableModelValidation="True" 
                                    AutoGenerateColumns="False" 
                                    CssClass="mGrid"
                                    PagerStyle-CssClass="pgr"
                                    AlternatingRowStyle-CssClass="alt"
                                    onrowcommand="editObjectGridView_RowCommand">
                                    <AlternatingRowStyle CssClass="alt" />
                                    <Columns>
                                        <asp:BoundField DataField="column_name" HeaderText="Column Name" HtmlEncode="false" />                                                     
                                        <asp:TemplateField HeaderText="Alias">
                                            <ItemTemplate>
                                                    <asp:TextBox ID="editAliasTextBoxID" runat="server"></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField> 
                                        <asp:TemplateField HeaderText="i" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="editInsertCheckBoxID" runat="server" />                               
                                            </ItemTemplate>
                                        </asp:TemplateField>                        
                                        <asp:TemplateField HeaderText="u" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="editUpdateCheckBoxID" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>    
                                        <asp:TemplateField HeaderText="s" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="15px">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="editSelectCheckBoxID" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>                
                                        <asp:TemplateField HeaderText="Objects">
                                            <ItemTemplate>
                                                    <asp:TextBox ID="editObjectTextBoxID" runat="server" Enabled="false"></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:ButtonField ButtonType="Link" CommandName="Select" HeaderText="[+]" text="[+]" />
                                    </Columns>
                                </asp:GridView>
                            </p>
                        </div>
                    </div>
                </div>

                <div style="float: left;" id="editObjectDivID" runat="server" visible="false">
                    <div class="module" style="width:250px;">
                        <div class="moduleHeader">Object - sheet</div>  
                        <div class="module_content">
                            <asp:HiddenField ID="editObjectHiddenFieldID" runat="server" />
                            <p id="p1" runat="server">
                                <label> Column name: </label>
                                <asp:Label ID="editColumnNameLabelID" runat="server"></asp:Label>
                            </p>
                            <p id="p2" runat="server">
                                <label> ToolBox: </label>
                                <asp:DropDownList Width="200px" ID="editObjectList" runat="server" DataTextField="ObjectName" DataValueField="ObjectID" onselectedindexchanged="editObjectList_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                            </p>
                            <p id="pEditTableID" runat="server" visible="false">
                                <label> Tabele: </label>
                                <asp:DropDownList Width="200px" ID="editTableList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="editDropDownList1_SelectedIndexChanged1"></asp:DropDownList>
                            </p>
                            <p id="pEditKeyID" runat="server" visible="false">
                                <label> Key.ID: </label>
                                <asp:DropDownList Width="200px" ID="editKeyRowsList" runat="server" DataTextField="column_name" DataValueField="column_name"></asp:DropDownList>                           
                            </p>
                            <p id="pEditColumnNameID" runat="server" visible="false">
                                <label> Column Name: </label>
                                <asp:DropDownList Width="200px" ID="editNameRowsList" runat="server" DataTextField="column_name" DataValueField="column_name"></asp:DropDownList>
                            </p> 
                             <p id="pEditSql" runat="server" visible="false">
                                <lable>SQL:</lable>
                                <asp:TextBox id="editSql" runat="server" Rows="7" TextMode="MultiLine"></asp:TextBox>
                            </p>
                            <asp:Button ID="editAddObjectButton"  runat="server" Text="Save" onclick="editObjectSaveButton_Click"   />
                            <asp:Button ID="editCancelObjectButton" runat="server" Text="Cancel"  onclick="editObjectCancelButton_Click"  />                            
                        </div>
                    </div>
                </div>

                <div style="float: left;">
                    <div class="module" style="width:auto;">                           
                        <div class="moduleHeader">Edit - sheet 2</div> 
                        <div class="module_content">                                    
                            <p>
                                <label> CSV Insert: </label>
                                <asp:TextBox ID="csvEditInsertTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p> <!-- ... -->    
                            <p>
                                <label> CSV Update: </label>
                                <asp:TextBox ID="csvEditUpdateTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p>
                            <p>
                                <label> CSV Select: </label>
                                <asp:TextBox ID="csvEditSelectTextBox" runat="server" Enabled="false"></asp:TextBox>
                            </p>                                    
                        </div>
                    </div>
                </div>

                <div style="float: left;">
                    <asp:Button ID="editSaveButton"  runat="server" Text="Save" onclick="editSaveButton_Click"   />
                    <asp:Button ID="editCancelButton" runat="server" Text="Cancel"  onclick="editCancelButton_Click"  />
                </div>

                <div class="clear"></div>
            </asp:Panel>
                        
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

